package logic

import (
	"context"
	"manager/model/mysql"

	"manager/merchantmanager/internal/svc"
	"manager/merchantmanager/merchantmanager"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddLogic {
	return &AddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *AddLogic) Add(in *merchantmanager.RequestAdd) (*merchantmanager.ResponseAdd, error) {
	// todo: add your logic here and delete this line
	data := mysql.Merchant{
		MerchantID:    int(in.MerchantID),
		MerchantName:  in.MerchantName,
		MerchantTypes: in.MerchantTypes,
		MerchantTime:  in.MerchantTime,
	}
	mysql.DB.Create(&data)
	return &merchantmanager.ResponseAdd{
		MerchantID: in.MerchantID,
	}, nil
}
